<template>
	<view style="height: 100vh; background-image: linear-gradient(#ff552f, #ff785a)">
		<swiper
			class="swiper"
			:current="current"
			:indicator-dots="true"
			:autoplay="false"
			indicator-color="rgba(255,255,255,0.55)"
			indicator-active-color="#FFF"
		>
			<swiper-item class="swiper-item">
				<image
					class="image"
					src="https://mcdn.chatgk.com/xcx/static/images/home/guide_1@2x.png"
					mode="aspectFit"
				></image>
			</swiper-item>
			<swiper-item class="swiper-item">
				<image
					class="image"
					src="https://mcdn.chatgk.com/xcx/static/images/home/guide_2@2x.png"
					mode="aspectFit"
				></image>
			</swiper-item>
			<swiper-item class="swiper-item">
				<image
					class="image"
					src="https://mcdn.chatgk.com/xcx/static/images/home/guide_3@2x.png"
					mode="aspectFit"
				></image>
			</swiper-item>
		</swiper>

		<button class="button" @tap="onClickOpenApp">开启{{ name }}</button>
		<view class="guide_popup" @tap.stop="() => {}" v-show="ishowbox">
			<view class="main">
				<view class="title">温馨提示</view>
				<view class="content">
					<view class="mainTitle">欢迎使用{{ name }}</view>
					<view class="mainCenter">
						<scroll-view scroll-y="true" style="height: 390rpx">
							1.为给您提供社区发布服务以及在线更新服务，在使用过程中我们可能会向您申请手机的储存权限、摄像头权限。
							<br />
							2.为给您提供基于您的位置向您推荐符合您的内容，使用过程中我们可能会向您申请您的位置权限。
							<br />
							3.为给您提供一键登录、信息推送以及账号安全，我们会申请系统设备权限收集手机设备信息、日志信息。
							<br />

							4.为给您提供快捷联系客服，使用过程中我们可能会申请拨打电话权限。
							<br />
							5.在您同意App隐私政策后，我们将进行集成
							SDK的初始化工作，会收集您的设备基础信息，以保障App正常数据统计和安全风控。
							<br />
							6.为方便您的查阅，可在新用户注册页面、登录
							APP后“我的-系统设置-隐私政策”查看完整版隐私政策内容。
						</scroll-view>
					</view>
				</view>
				<view class="xieyi">
					您可以阅读完整版
					<text style="color: #ff3b0a" @tap="privacyPolicy">隐私政策</text>
				</view>
				<view class="footer">
					<view class="footerbox" style="margin-right: 100rpx" @click="onquxiao">不同意</view>
					<view class="footerbox sel" @tap.stop="onYesDeal">同意并登陆</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import xcxInfo from '@/common/manager/xcxInfo.js';
export default {
	data() {
		return {
			current: 0,
			ishowbox: true,
			name: xcxInfo.name
		};
	},
	onShow() {
		uni.setStorageSync('isAgree', false);
	},
	methods: {
		privacyPolicy() {
			uni.navigateTo({
				url: '/subpackages/subpackage1/pages/privacyPolicy/privacyPolicy'
			});
		},
		onquxiao() {
			if (uni.getSystemInfoSync().platform == 'ios') {
				// this.ishowbox = false
				plus.ios.import('UIApplication').sharedApplication().performSelector('exit');
			} else if (uni.getSystemInfoSync().platform == 'android') {
				plus.runtime.quit();
			}
		},
		onYesDeal() {
			uni.setStorageSync('isAgree', true);
			this.ishowbox = false;
		},
		onClickOpenApp() {
			if (this.current == 2) {
				const userInfo = getApp().globalData.userInfo;
				const firstLogin = uni.getStorageSync('isFirstLogin');
				const isfirstLogin = !Boolean(firstLogin);

				uni.setStorageSync('isNewUser', true);

				if (userInfo || !isfirstLogin) {
					if (!userInfo) {
						uni.switchTab({
							url: '/pages/tabBar/home/home'
						});
					} else if (!userInfo.pid) {
						uni.redirectTo({
							url: '/subpackages/subpackage2/pages/login/perfect-info'
						});
					} else if (!userInfo.score) {
						uni.redirectTo({
							url:
								'/subpackages/subpackage1/pages/score/home-score?data=' +
								JSON.stringify({
									isLoginPush: true
								})
						});
					} else {
						uni.switchTab({
							url: '/pages/tabBar/home/home'
						});
					}
				} else {
					uni.redirectTo({
						url: '/pages/login/login-home?isNavBack=0'
					});
				}
			} else {
				this.current += 1;
			}
		}
	}
};
</script>

<style scoped>
.guide_popup {
	width: 100vw;
	height: 100vh;
	position: fixed;
	top: 0;
	z-index: 2;
	display: flex;
	justify-content: center;
	align-items: center;
	background-color: rgba(0, 0, 0, 0.3);
}

.main {
	width: 686rpx;
	height: 774rpx;
	background: #ffffff;
	border-radius: 20rpx;
	padding: 0 18rpx;
	box-sizing: border-box;
}

.title {
	width: 100%;
	margin-top: 52rpx;
	display: flex;
	justify-content: center;
	align-items: center;
	font-size: 36rpx;
	font-weight: 600;
	color: #333333;
}

.content {
	width: 100%;
	font-weight: 600;
}

.xieyi {
	padding-top: 28rpx;
	font-size: 28rpx;
	font-family: PingFangSC-Semibold, PingFang SC;
	font-weight: 600;
	color: #333333;
}

.mainTitle {
	color: #333333;
	font-size: 32rpx;
}

.mainCenter {
	font-size: 32rpx;
	color: #999999;
}

.footer {
	width: 100%;
	height: 70rpx;
	display: flex;
	justify-content: center;
	align-items: center;
	margin-top: 36rpx;
}

.footerbox {
	width: 222rpx;
	height: 64rpx;
	border-radius: 32rpx;
	border: 2rpx solid #979797;
	font-size: 28rpx;
	font-family: PingFangSC-Semibold, PingFang SC;
	font-weight: 600;
	color: #999999;
	display: flex;
	justify-content: center;
	align-items: center;
}

.sel {
	color: #ffffff;
	background: linear-gradient(180deg, #ff3b0a, #ff7e36);
	border: none;
}

.swiper {
	height: 97vh;
	width: 100vw;
	background-image: linear-gradient(#ff552f, #ff785a);
}

.swiper-item {
	display: block;
	height: 100%;
	width: 100%;
	text-align: center;
	background-color: blue;
}

.image {
	width: 100%;
	height: 100%;
	background-image: linear-gradient(#ff552f, #ff785a);
}

.button {
	margin-top: -170rpx;
	width: 656rpx;
	height: 98rpx;
	border: white 4rpx solid;
	border-radius: 49rpx;
	color: white;
	font-size: 36rpx;
	font-weight: bold;
	background-color: transparent;
}
</style>
